<template>
	<Modal v-model="modal" title="退款详情">
		<Form ref="formValidate" :label-width="100">
			<FormItem label="退款状态:">
				{{['待审核', '待发货', '审核未通过','待收货','待退款','待确认','退款完成'][returnInfo.returnType]}}
			</FormItem>
			<FormItem label="退款单号:">
				{{returnInfo.orderNum}}
			</FormItem>
			<FormItem label="提交日期:">
				{{returnInfo.createTime | timeForm }}
			</FormItem>
			<FormItem label="会员:" class="_border">
				{{returnInfo.buyersTel }}
			</FormItem>
			<FormItem label="退货原因:">
				{{returnInfo.refundReason }}
			</FormItem>
			<FormItem label='退款总额:' v-if="returnInfo.car">
				{{returnInfo.car.carMoney}}万元
			</FormItem>
			<FormItem label='退款方式:' class="_border">
				线下转账
			</FormItem>
			<FormItem label='卖家：'>
				{{returnInfo.sellerTel }}
			</FormItem>
			<FormItem class="_border" v-if="returnInfo.car">
				<div class="serve-img-box">
					<img :src="returnInfo.car.carPhoto" alt="" />
					<div class="_carName">
						<span>{{returnInfo.car.carName}}</span>
						<span>{{returnInfo.car.typeName}}</span>
					</div>

				</div>
			</FormItem>
			<div v-if="returnInfo.returnType!=0">
				<FormItem label='审核时间：'>
					{{returnInfo.auditTime | timeForm }}
				</FormItem>
				<FormItem label='日租费用：' class="returnInfo.returnType!=1?'_border'">
					￥{{returnInfo.dayCost }}
				</FormItem>
			</div>
			<div v-if="returnInfo.returnType!=0 && returnInfo.returnType!=1">
				<FormItem label='发货日期：'>
					{{returnInfo.deliveryDate}}
				</FormItem>
				<FormItem label='物流公司：'>
					{{returnInfo.logisticsCompany }}
				</FormItem>
				<FormItem label='物流单号：'>
					{{returnInfo.singleNumber }}
				</FormItem>
				<FormItem label='发货人：'>
					{{returnInfo.consignor }}
				</FormItem>
				<FormItem label='手机：'>
					{{returnInfo.consignorTel }}
				</FormItem>
				<FormItem label='备注：' class="_border">
					{{returnInfo.note }}
				</FormItem>
				<FormItem label='租赁天数：'>
					{{returnInfo.leaseDay }}
				</FormItem>
				<FormItem label='租赁费用：' class="_border">
					￥{{returnInfo.leaseMoney }}
				</FormItem>
				<FormItem label='应退金额：' v-if="returnInfo.backMoney" v-bind:class="returnInfo.returnType!=3?'_border':''">
					{{returnInfo.backMoney }}万元
				</FormItem>
			</div>
			<div v-if="returnInfo.returnType==4 || returnInfo.returnType==5 || returnInfo.returnType==6">
				<FormItem label='收货日期：'>
					{{returnInfo.confirmTime  }}
				</FormItem>
			</div>
			<div v-if="returnInfo.returnType==5 || returnInfo.returnType==6 ">
				<FormItem label='退款日期：'>
					{{returnInfo.refundDate }}
				</FormItem>
				<FormItem label='退款凭证：'>
			
				</FormItem>
				<FormItem  v-if="returnInfo.buyersProof || returnInfo.sellerProof">
					<Row >
						<i-col span="8"  v-if="returnInfo.buyersProof">
							<div class="serve-img-box" style="text-align: center;">
								<img :src="returnInfo.buyersProof" alt=""/>
								<div >应退金额</div>
							</div>
						</i-col>
						<i-col span="8"  v-if="returnInfo.sellerProof">
							<div class="serve-img-box" style="text-align: center;">
								<img :src="returnInfo.sellerProof" alt=""/>
								<div >租赁费用</div>
							</div>
						</i-col>
					</Row>

				</FormItem>
				<FormItem label='备注:'>
					{{returnInfo.platformNote }}
				</FormItem>
				<FormItem label='会员确认日期:'>
					{{returnInfo.buyersTime | timeForm}}
				</FormItem>
				<FormItem label='卖家确认日期:'>
					{{returnInfo.sellerTime | timeForm}}
				</FormItem>
			</div>

		</Form>
		<div slot="footer">
			<Button @click="cancel" v-if="returnInfo.returnType!=4 && returnInfo.returnType!=5">返回</Button>

			<Button type="primary" @click="returns(returnInfo)" :loading="loadingBtn" v-if="returnInfo.returnType==4">
				<span v-if="!loadingBtn">退款</span>
				<span v-else>请稍候...</span>
			</Button>
			<div  v-if="returnInfo.returnType==5">
				<Button type="primary" @click="edit(returnInfo)" :loading="loadingBtn" v-if="isShowBtn">
					<span v-if="!loadingBtn">修改</span>
					<span v-else>请稍候...</span>
				</Button>
				<Button type="primary" @click="edit(returnInfo)" :loading="loadingBtn" v-if="isDisShowBtn" disabled>
					<span v-if="!loadingBtn">修改</span>
					<span v-else>请稍候...</span>
				</Button>
			</div>
			
			
		</div>
		<returnModal ref="returnModal" :type='modalType'></returnModal>
	</Modal>
</template>

<script>
	import returnModal from './returnModal'
	export default {
		components: {
			returnModal
		},
		props: {
			type: String
		},
		data() {
			return {
				modal: false,
				returnInfo: {},
				returnId: 0,
				loadingBtn: false,
				modalType: '',
				isShowBtn:false,
				isDisShowBtn:false
			}
		},
		methods: {

			show(res) {
				this.$nextTick(() => {
					this.modal = true
					this.returnId = res.row.returnId
					this.$http.post('old/return/queryid', {
						id: res.row.returnId
					}).then(res => {
						if (res.status == 200) {
							if (res.data.code == 200) {
								this.returnInfo = res.data.data
								if(res.data.data.sellerReceipt==0 && res.data.data.buyersReceipt==0){
									this.isShowBtn =true
									this.isDisShowBtn = false
								}else {
									this.isShowBtn =false
									this.isDisShowBtn = true
								}
							}

						}

					})

				})

			},

			//取消
			cancel() {
				this.modal = false;
			},
			//上传成功
			imgUploadSuccess(res) {
				this.editData.userPhoto = res.res.filePath;
			},
			//退款
			returns(res) {
				this.modal = false;
				this.modalType = 'add'
				this.$refs['returnModal'].show(res)
			},
			//修改
			edit(res) {
				this.modal = false;
				this.modalType = 'edit'
				this.$refs['returnModal'].show(res)
			},
			modalChange(state) {
				if (state) {

				} else {
					this.$refs.formValidate.resetFields()
				}
			}
		}
	}
</script>
<style scoped>
	.uploadSuccess {
		width: 200px;
		height: 100px;
	}

	.serve-img-box img {
		text-align: center;
		width: 80px;
		height: 60px;
	}

	._carName {
		display: inline-block;
		margin: 10px 0 0 10px;
		position: absolute
	}

	.ivu-form-item {
		margin-bottom: 2px;
	}

	._border {
		padding-bottom: 10px;
		border-bottom: 1px solid #D7DDE4;
	}
	
</style>
